#!/usr/bin/env python3
import os
import sys
path = sys.path[0]
print('path:', path)
sys.path.append(path)
sys.path.insert(0,'/opt/ros/' + os.environ['ROS_DISTRO'] + '/lib/python3/dist-packages/')
import rospy


env_path = os.path.join(os.path.dirname(__file__), '..')
if env_path not in sys.path:
    sys.path.append(env_path)

from pytracking.evaluation import Tracker

  
def run_rosmsg(tracker_name, tracker_param, sub_topic, pub_topic, debug=None):
    """Run the tracker on the receiving ROS image msg.
    args:
        tracker_name: Name of tracking method.
        tracker_param: Name of parameter file.
        sub_topic: ROS topic for subscriber.
        pub_topic: ROS topic for publisher.
        debug: Debug level.
    """
    tracker = Tracker(tracker_name, tracker_param)
    tracker.run_ros_msgs(debug=debug, sub_topic=sub_topic, pub_topic=pub_topic)


def main():
    rospy.init_node('keeptrack_tracker', anonymous=True)
    sub_topic = rospy.get_param('~camera_topic', '')
    pub_topic = rospy.get_param('~pub_topic', '')
    tracker_name = rospy.get_param('~tracker_name', '')
    tracker_param = rospy.get_param('~tracker_param', '')
    run_rosmsg(tracker_name, tracker_param, sub_topic, pub_topic)
    rospy.spin()


if __name__ == '__main__':
    main()
